//右边栏条控制
var personal_bar=document.querySelector(".personal_bar");
var h3_person=personal_bar.getElementsByTagName("h3");
var ul_person=personal_bar.getElementsByTagName("ul");
var iconfont=personal_bar.getElementsByClassName("iconfont");
for(var i=0; i<h3_person.length; i++){
	h3_person[i].onclick=function(){
		var bb;
		if(this.className==''){
			this.className='op';
		}
		else{
			this.className='';	
		}
		this.setAttribute('flash','true');
		for(var j=0;j<h3_person.length;j++){
			if(h3_person[j].getAttribute('flash')=='true')
			{
				bb=j;
				h3_person[j].removeAttribute('flash');
			}
		}		
		if(ul_person[bb].className==''){
			ul_person[bb].className='hide';
			ul_person[bb].style.height='0';
			iconfont[bb].style.transform='rotate(270deg)'
			
		}
		else{
			var height=ul_person[bb].getElementsByTagName('li').length*30;
			ul_person[bb].className='';
			ul_person[bb].style.height=height+'px';
			iconfont[bb].style.transform='rotate(90deg)'
		}
	}		
}

for(var i=0;i<ul_person.length;i++){
	var hh=ul_person[i].getElementsByTagName('li').length*30;
	ul_person[i].style.height=hh+'px';
}
	

//搜索栏判断
var search_top=document.querySelector("#search_top"),
	input_on=document.querySelector(".input_on");
	
	search_top.addEventListener("focus",function(){//提取焦点
		input_on.style.display='none';
	})
	search_top.addEventListener("blur",function(){//移出
		input_on.style.display='block';
	})
	
//点击关闭图片
var close_img=document.querySelector(".top_img .close_top_img");
var top_img=document.querySelector(".top_img");
	close_img.onclick=function(){
		setTimeout(function(){
			top_img.style.display='none';
		},500)
	}
	
//三级联
var province_info = [
		{ "GD": "广东省" },
		{ "HN": "湖南省" },
		{ "HB": "湖北省" },
		{ "JS": "江苏省" }
	]
var city_info = {
	"GD": [
		{ "0": "广州市" },
		{ "1": "深圳市" },
		{ "2": "韶关市" },
		{ "3": "佛山市" }
	],
	"HN": [
		{ "0": "长沙市" },
		{ "1": "株洲市" },
		{ "2": "衡阳市" }
	],
	"HB": [
		{ "0": "宜昌市" },
		{ "1": "武汉市" }
	],
	"JS":[
		{ "0": "长沙市" },
		{ "1": "株洲市" },
		{ "2": "衡阳市" }			
	],
}
	

var state=document.querySelector(".state"),
	city=document.querySelector(".city"),
	county=document.querySelector(".county");
	
	//省份添加
	for(var i=0;i<province_info.length;i++){
		for(var k in province_info[i]){
			state.innerHTML+="<option value='"+k+"'>"+province_info[i][k]+"</option>";
		}
	}
	
	//城市添加
	state.addEventListener("change",function(){
		city.innerHTML="<option selected='selected' disabled='disabled'>"+"请选择城市"+"</option>";
		var s=this.value;
		console.log(city_info[s])
		for(var j=1;j<city_info[s].length;j++){
			for(var k in city_info[s][j]){
				city.innerHTML+="<option value='"+k+"'>"+city_info[s][j][k]+"</option>";
			}
		}
	})
	
//var h3_person=document.querySelectorAll(".personal_bar .list_person h3");
//var li_person=document.querySelectorAll(".personal_bar .list_person ul li");
//var ul_person=document.querySelectorAll(".personal_bar .list_person ul");
//for(var i=0;i<h3_person.length;i++){	
//	(function(k){
//		h3_person[k].addEventListener("click",function(){
//			ul_person[k].style.height='0'
//		})
//	})(i)
//}
